//
// Created by tang on 2022/10/24.
//

#ifndef LEARNOPENGL_TEXTURE_HPP
#define LEARNOPENGL_TEXTURE_HPP

#include "gl/gl_validation.hpp"

namespace GL
{
    SHARED_HANDLE(Texture);

    class Texture final {
    public:
        Texture();
        Texture(const std::string& asset_name);
        ~Texture();

        bool Load(const std::string& asset_name);
        bool Upload(GLint width, GLint height, GLenum format, GLenum type, void *data);

        void* TexID() const;
        glm::vec2 Size() const;

        GLint Width() const;
        GLint Height() const;

        operator void*() const;
        operator glm::vec2() const;
        operator GLuint() const;

        FACTORY_METHOD(Texture, const std::string &asset_name);
        FACTORY_METHOD(Texture);

    private:
        void Clean();

        GLuint m_handle_;
        GLint  m_width_;
        GLint  m_height_;
    };
}

#endif//LEARNOPENGL_TEXTURE_HPP
